import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:village_android/config/contants.dart';

class AddressYearWidget extends StatefulWidget {
  @override
  _AddressYearWidgetState createState() => _AddressYearWidgetState();
}

class _AddressYearWidgetState extends State<AddressYearWidget> {

  String _year = "2019";

  @override
  Widget build(BuildContext context) {
    return getAddressYearWidget(context);
  }

  Widget getAddressYearWidget(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
      height: 65,
      color: Colors.white,
      child: Container(
        padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
        color: Colors.red,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Expanded(
              child: FlatButton(
                onPressed: () => {},
                color: Colors.transparent,
                padding: EdgeInsets.all(5.0),
                child: Column(
                  // Replace with a Row for horizontal icon + text
                  children: <Widget>[
                    Text(
                      "地吱吱吱吱资质",
                      style: TextStyle(color: Colors.white),
                    ),
                    Image.network(
                      kImageHost + "qihua_white.png",
                      height: 20,
                      width: 20,
                      fit: BoxFit.fill,
                    ),
                  ],
                ),
              ),
            ),
            Spacer(),
            Expanded(
              child: FlatButton(
                onPressed: () => {

                   DatePicker.showDatePicker(context,
                      showTitleActions: true,
                      minTime: DateTime(2000, 1, 1),
                      maxTime: DateTime(2099, 1, 1), onChanged: (date) {
                    print('change $date');
                  }, onConfirm: (date) {
                     setState(() {
                       _year = date.year.toString();
                       print('confirm $date');
                     });
                  }, currentTime: DateTime.now(), locale: LocaleType.zh)
                },
                color: Colors.transparent,
                padding: EdgeInsets.all(5.0),
                child: Column(
                  // Replace with a Row for horizontal icon + text
                  children: <Widget>[
                    Text(
                      "年份：" + _year,
                      style: TextStyle(color: Colors.white),
                    ),
                    Image.network(
                      kImageHost + "qihua_white.png",
                      height: 20,
                      width: 20,
                      fit: BoxFit.fill,
                    ),
                  ],
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
